package GradeManager.StudentGradeSystem.controller;

import GradeManager.StudentGradeSystem.pojo.PageBean;
import GradeManager.StudentGradeSystem.pojo.Result;
import GradeManager.StudentGradeSystem.pojo.Student;
import GradeManager.StudentGradeSystem.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService service;
//    获取学生表格数据返回给前端
    @GetMapping
    public Result tableInit(int currentPage, int pageSize){
        PageBean<Student> pageBean = service.initTable(currentPage,pageSize);
        return Result.success(pageBean);
    }
//    获取满足条件的学生数据
    @PostMapping("/selectByCondition")
    public Result selectByCondiytion(@RequestBody Student studentCondition, int currentPage, int pageSize){
        PageBean<Student> pageBean = service.searchByCondition(studentCondition, currentPage, pageSize);
        return Result.success(pageBean);
    }
}
